<?php namespace Home\Controller; 

use Hdphp\Controller\Controller;

//购物车结算控制器(用的是cart表)
class OrderPageController extends Controller{
	private $model;
	private $uid = null;   //这里得进行私有
	public function __init(){
		$this->model = new \Common\Model\Cart;
		if(isset($_SESSION['uinfo']['uid'])){
			$this->uid = $_SESSION['uinfo']['uid'];
			// p($uid);
		}
	}

	public function index(){
		if($_POST){  //这儿处理的是从pay页面提交过来的数据,用于展示商品用的
			if(!empty($_POST)){
				$_SESSION['gid'] = $_POST;
			}
		}
		// p($_SESSION);
		$id = implode(',',$_SESSION['gid']['GoodsId']);
		// p($id);
		$GoodsModel = new \Common\Model\Goods;
		$pic = $GoodsModel->where("gid in($id)")->lists('pic');
    	// p($pic);
		$goodsData = $this->model->where("id in($id)")->get();
		$total = 0;
		foreach ($goodsData as $key => $value) {
			foreach ($pic as $k => $v) {
				$goodsData[$key]['pic']= $v;
				$goodsData[$key]['xiaoji'] = $value['num'] *$value['price'];
				$goodsData[$key]['size'] = explode(',',$value['size']);
			}
				$total += $goodsData[$key]['xiaoji'];
		}
		// p($goodsData);
		$this->assign('goodsData',$goodsData);
		$this->assign('total',$total);
		$this->display();
	}
	public function AjaxAddress(){
		$uid = $this->uid;
		$OrderModel = new \Common\Model\Order1;
		if($OrderModel->address($_POST,$uid)){
		
		}
		
	}
}
?>